package com.ctshk.rpc.payment.dto.req.unionpay;

import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @BelongsProject: ctshk-cloud
 * @BelongsPackage: com.ctshk.rpc.payment.dto.req.unionpay
 * @Author: hef
 * @CreateTime: 2021-05-07 16:59
 * @Description: 描述
 */
@Data
public class UnionPayRefundReq extends UnionPayCommonReq {
    /**
     * 原始消费交易的queryId
     */
    private String origQryId;
    /**
     * 渠道类型
     */
    private String channelType;
    /**
     * 退货金额，单位分，不要带小数点。退货金额小于等于原消费金额，当小于的时候可以多次退货至退货累计金额等于原消费金额
     */
    private String txnAmt;
    /**
     * 结算货币
     */
    private String currencyCode;
    /**
     * 回调地址
     */
    private String backUrl;

    public UnionPayRefundReq(String merId, String orderId, String origQryId, BigDecimal txnAmt,String currencyCode,String backUrl) {
        super("000802", "04", "00", merId, orderId,
                LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
        this.origQryId = origQryId;
        this.channelType = "07";
        this.txnAmt = String.valueOf(txnAmt.multiply(BigDecimal.valueOf(100)).longValue());
        this.currencyCode = currencyCode;
        this.backUrl = backUrl;
    }
}
